﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admins_logon : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        txtUsername.Focus(); 
    }
    protected void btnLogon_Click(object sender, EventArgs e)
    {
        TaiKhoan taiKhoan = new TaiKhoan();
        ObjTaiKhoan objTaiKhoan = new ObjTaiKhoan();
        Utils utils = new Utils();
        objTaiKhoan.User_name = txtUsername.Text;
        objTaiKhoan.Pass = utils.getMD5(txtPassword.Text);
        //objTaiKhoan.Pass = txtPassword.Text; 
        objTaiKhoan = taiKhoan.logIn(objTaiKhoan);
        if (objTaiKhoan.User_id != 0)
        {
            Session["user_id"] = objTaiKhoan.User_id;
            Session["user_name"] = objTaiKhoan.User_name;
            Response.Redirect("/admins/");
            
        }
            
        else
        {
            ltrError.Text = "Lỗi đăng nhập";
        }
    }
}